home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / PopupCDEF 1.0b3 / PopupLib.h < prev   
Text File  |  1994-03-16  |  5KB  |  121 lines

  1. /* See the file Distribution for distribution terms.
  2.     (c) Copyright 1994 Ari Halberstadt */
  3.     
  4. #pragma once
  5.  
  6. #include "PopupCDEF.h"
  7.  
  8. #ifndef arrowCursor
  9.     /* arrowCursor is defined in DrawLib.h,
  10.         which also defines TextState */
  11.     typedef struct {
  12.         short    font;
  13.         Style    face;
  14.         short    mode;
  15.         short    size;
  16.     } TextState;
  17. #endif /* arrowCursor */
  18.  
  19. /* Drawing environment data which must be remembered before any drawing
  20.     of the popup menu is begun and restored after all drawing has finished. */
  21. typedef struct {
  22.     GrafPtr        port;            /* graf port on entry to popup cdef */
  23.     PenState        pen;            /* saved pen state for popup's port */
  24.     TextState    text;            /* saved text state for popup's port */
  25.     RgnHandle    clip;            /* saved clip region for popup's port */
  26.     short            sysfont;        /* saved system font */
  27.     short            syssize;        /* saved system font size */
  28. } PopupEnvType;
  29.  
  30. /* rectangles defining the various areas of a popup menu */
  31. typedef struct {
  32.     Rect maxbounds;            /* maximum bounding rectangle of popup */
  33.     Rect bounds;                /* rectangle around all of popup */
  34.     Rect hilite;                /* hilited when a selection is being made */
  35.     Rect title;                    /* contains the popup's title */
  36.     Rect selection;            /* contains the currently selected item */
  37.     Rect arrow;                    /* contains the down arrow */
  38. } PopupRectanglesType;
  39.  
  40. /* structure containing all the data needed by the popup menu */
  41. typedef struct {
  42.  
  43.     /* these first two fields will never be changed, other fields may change */
  44.     PopupPrivateType private;    /* for compatability with Apple's CDEF */
  45.     short                version;        /* version of the code that created this popup menu */
  46.  
  47.     /* fields specified on creation of the popup menu (maxbounds is in
  48.         rectangles field) */
  49.     GrafPtr            port;            /* port to draw into */
  50.     MenuHandle        menu;            /* handle to menu */
  51.     
  52.     /* offscreen bitmap handles */
  53.     RgnHandle        utilRgn;        /* utility region */
  54.     Handle            baseAddr;    /* bitmap's base address */
  55.     
  56.     /* internal state information */
  57.     PopupRectanglesType r;        /* rectangles enclosing areas of the popup menu */
  58.     struct {
  59.         PopupEnvType oldenv;     /* old drawing environment */
  60.         MenuHandle    selection;    /* menu containing the currently selected item */
  61.         short            current;        /* currently selected item number */
  62.         Boolean        envset:1;    /* true after drawing environment has been setup */
  63.         Boolean        gotmenu:1;    /* used by CDEF; true means CDEF created menu */
  64.     } state;
  65.     
  66.     /* User settable attributes of the menu. External functions
  67.         are provided to manipulate these fields. */
  68.     struct {
  69.         void            *data;        /* pointer to application defined data */
  70.         Boolean        draw:1;        /* false disables drawing and calculating */
  71.         Boolean        visible:1;    /* true means popup is visible */
  72.         Boolean        enabled:1;    /* true if menu is enabled */
  73.         Boolean        typein:1;    /* true shows only arrow, like a type-in menu */
  74.         Boolean        wfont:1;        /* true uses window font, not system font */
  75.         Boolean        fixedwidth:1;/* true uses fixed width for menu */
  76.         char            mark;            /* character used to mark current item */
  77.         char            just;            /* text justification */
  78.         struct {
  79.             Style        style;        /* style of popup's title */
  80.             short        width;        /* width of title; 0 if resized dynamically */
  81.             Handle    str;            /* popup's title string */
  82.         } title;
  83.     } attr;
  84. } PopupType, *PopupPtr, **PopupHandle;
  85.  
  86. Boolean PopupValid(PopupHandle popup);
  87.  
  88. void PopupCalculate(PopupHandle popup);
  89. void PopupDraw(PopupHandle popup);
  90. void PopupHilite(PopupHandle popup);
  91. void PopupSelect(PopupHandle popup);
  92. Boolean PopupWithin(PopupHandle popup, Point pt);
  93.  
  94. short PopupVersion(PopupHandle popup);
  95. short PopupCurrent(PopupHandle popup);
  96. void PopupCurrentSet(PopupHandle popup, short current);
  97. void PopupDrawSet(PopupHandle popup, Boolean draw);
  98. void PopupVisibleSet(PopupHandle popup, Boolean visible);
  99. void PopupMarkSet(PopupHandle popup, char mark);
  100. void PopupEnableSet(PopupHandle popup, Boolean enabled);
  101. void PopupTypeInSet(PopupHandle popup, Boolean typein);
  102. void PopupBounds(PopupHandle popup, Rect *bounds);
  103. void PopupBoundsSet(PopupHandle popup, const Rect *bounds);
  104. void PopupTitle(PopupHandle popup, Str255 title);
  105. void PopupTitleSet(PopupHandle popup, const Str255 title);
  106. void PopupTitleWidthSet(PopupHandle popup, short width);
  107. void PopupTitleStyleSet(PopupHandle popup, Style style);
  108. void PopupUseWFontSet(PopupHandle popup, Boolean wfont);
  109. void PopupFixedWidthSet(PopupHandle popup, Boolean fixedwidth);
  110. void PopupJustSet(PopupHandle popup, short just);
  111.  
  112. PopupHandle PopupBegin(GrafPtr port, MenuHandle menu, const Rect *bounds);
  113. void PopupEnd(PopupHandle popup);
  114.  
  115. pascal long PopupCDEF(short var, ControlHandle ctl, short msg, long param);
  116. void PopupCDEFAttach(ControlHandle ctl);
  117. void PopupCDEFDetach(ControlHandle ctl);
  118.  
  119. const /* EventTableType */ void *PopupEventTable(void);
  120. void PopupEventTableRegister(void);
  121.